#!/usr/bin/env python
import sys
import urllib2

import tornado.escape

import config as C

def call_service(url, text):
    args = {
        'word': text,
    }
    try:
        resp = urllib2.urlopen(url, data=tornado.escape.json_encode(args))
        print 'Response: %s' % '\n'.join(resp.readlines())
    except Exception, e:
        print 'Error: %s' % e

if __name__ == '__main__':
    C.init()
    text = sys.stdin.readlines()[0].replace('\n', '')
    url = C.get_config(C.EXT_SECTION, 'lookup_dictionary_service_address')
    call_service(url, text)

